<!DOCTYPE html>
<html lang="en">

	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		<meta http-equiv="X-UA-Compatible" content="ie=edge">
		<title>登录</title>
		<script src="js/rem.js"></script>
		<script type="text/javascript" src="js/xzx-api.js">
		</script>
		<script type="text/javascript" src="js/axios.min.js">
		</script>
		<link rel="stylesheet" href="font/iconfont.css">
		<link rel="stylesheet" href="css/base.css">
		<link rel="stylesheet" href="css/master.css">
	</head>

	<body>
		<div id="container">
			<div id="login">
				<p>登录</p>
				<input class="text" id="userName" type="text" placeholder="用户名">
				<input class="password" id="passWord" type="text" placeholder="密码">
				<a href="resetpassword.html">忘记密码？</a>
				<button class="loginBtn">登录</button>
				<span>还没有账号？</span>
				<a href="reg.html" class="regBtn">注册</a>

			</div>
		</div>
		<script type="text/javascript">
			let btn=document.querySelector(".loginBtn");
			btn.onclick = function() {
				let username = userName.value;
				let password = passWord.value;
				axios.get(loginAPI, {
					params: {
						username,
						password
					}
				}).then(res => {
					// console.log(res);
					if (res.data.code) {
						alert(res.data.msg);
						localStorage.setItem("uid", res.data.data.id);
						localStorage.setItem("token", res.data.data.token);
						localStorage.setItem("username", res.data.data.username);
						location.href = "recommend-beijing.html";
					} else {
						alert(res.data.msg);
					}
				}).catch(error => {
					alert(error);
				})
			}
		</script>
	</body>

</html>
